Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] BigQuery handler for enrichment transform #31295

Merged
merged 8 commits into from
May 17, 2024

Conversation

riteshghorse
Copy link
Contributor

@riteshghorse riteshghorse commented May 14, 2024

Implemented the BigQuery handler for Enrichment transform.

To use this handler you need either of the following combinations:

  1. table_name, row_restriction_template, fields
  2. table_name, row_restriction_template, condition_value_fn
  3. query_fn

In addition to this, batch size can be specified with min_batch_size and max_batch_size. These are passed to the BatchElements transform just before making calls to BigQuery. This helps reducing the cost on the BigQuery side.

By default, the handler pulls all columns from the BigQuery table. To override this, use the column_name parameter to specify a list of column names to fetch.

The user interface here is pretty similar to TableReadOptions.

Example Usage:

handler = BigQueryEnrichmentHandler(
        project=PROJECT_ID,
        row_restriction_template="id='{}'",
        table_name=TABLE_NAME,
        fields=['id'],
        min_batch_size=2,
        max_batch_size=100,
    )

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@github-actions github-actions bot added the build label May 15, 2024
@riteshghorse riteshghorse marked this pull request as ready for review May 15, 2024 18:37
@riteshghorse
Copy link
Contributor Author

R: @damccorm

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

Copy link
Contributor

@damccorm damccorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, had some minor comments

@riteshghorse
Copy link
Contributor Author

Thanks for the review! Made the suggested changes.

Copy link
Contributor

@damccorm damccorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once checks pass, thanks!

@riteshghorse
Copy link
Contributor Author

BigQuery tests passed in 3.9-
image

Known failure in PostCommit 3.8 due to dependency conflicts

@riteshghorse riteshghorse merged commit 44177d1 into apache:master May 17, 2024
81 of 82 checks passed
@riteshghorse riteshghorse deleted the bq-enrichment branch May 17, 2024 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants